﻿//创建时间: 2011-04-12
//创建作者: 张晓举
//功能说明: 用户编辑个人信息 
//最后修改: 2011-04-12
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;
using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Collections;
using TRPOP.CMS.UserManage;

namespace TRPOP.CMS.Web.Admin
{
    public partial class UserSelf_save : BaseAdmin
    {
        #region 页面变量
        protected string m_title = "添加";
        protected AdminUserInfo mAdminUserBaseInfo = new AdminUserInfo();
        protected string strpwdInfo = "";
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (TRPOP.CMS.Plugin.VersionLimit.IsDemo)
            {
                base.ExecuteJsWidthEnd("alert('当前Demo版本不支持个人信息修改!');");
                return;
            }

            if (!IsPostBack)
            {
                LoadBase();
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            mAdminUserBaseInfo = base.m_IAdminUser.getUserBaseInfo() as AdminUserInfo;

            strpwdInfo = "如果未输入，则不修改密码";

            mAdminUserBaseInfo.Sex = rbtSex.SelectedIndex <= 0;
            mAdminUserBaseInfo.LogPWD = mAdminUserBaseInfo.LogPWD.IsEmpty() ?
                                    ("123456".MD5Normal()) :
                                    mAdminUserBaseInfo.LogPWD;
            if (txtPWD1.Text.Trim().IsEmpty() == false)
                mAdminUserBaseInfo.LogPWD = txtPWD1.Text.Trim().MD5Normal();

            SubmitAlert(m_IAdminUser.SaveUserInfo(mAdminUserBaseInfo));

            base.SaveLog(Plugin.LogKeys.OperObject.AdminOper, Plugin.LogKeys.OperResult.EditSubmit, mAdminUserBaseInfo.UserBaseId.ToString());
        }
        #endregion

        #region 页面方法

        public void LoadBase()
        {
            mAdminUserBaseInfo = base.m_IAdminUser.getUserBaseInfo() as AdminUserInfo;
            strpwdInfo = "如果未输入，则不修改密码";
            InitPageViewState("model", mAdminUserBaseInfo);
            m_title = "编辑";
            txtLogName.Text = mAdminUserBaseInfo.LogName;
            txtName.Text = mAdminUserBaseInfo.Name;
            rbtSex.SelectedValue = mAdminUserBaseInfo.Sex.ToString().ToLower();
        }
        #endregion
    }
}